package nc.bs.hrhi.bp;

import nc.bs.dao.DAOException;
import nc.vo.hi.qys.QysOperVO;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.AppContext;
import nc.vo.pubapp.pattern.pub.SqlBuilder;

public class QysLxOperBp extends AbsPubOp{

	public void exec(String pk_qyschoose, String[] pk_psndocs) throws BusinessException{
		delete(pk_psndocs);
		
		insert(pk_qyschoose, pk_psndocs);
		
	}

	private void insert(String pk_qyschoose, String[] pk_psndocs) throws DAOException {
		QysOperVO[] opers = new QysOperVO[pk_psndocs.length];
		for(int i = 0;i < opers.length; i ++) {
			opers[i] = new QysOperVO();
			opers[i].setPk_psndoc(pk_psndocs[i]);
			opers[i].setPk_qyschoose(pk_qyschoose);
			opers[i].setDr(0);
			opers[i].setTs(AppContext.getInstance().getServerTime());
		}
		
		getDao().insertVOArray(opers);
	}

	private void delete(String[] pk_psndocs) throws DAOException {
		SqlBuilder sqlB = new SqlBuilder();
		
		sqlB.append("delete smg_pay_qyschoose_oper where pk_psndoc", pk_psndocs);
		
		getDao().executeUpdate(sqlB.toString());
	}
}
